import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '缩略图',
    align:"center",
    dataIndex: 'thumbnail',
    customRender:render.renderImage,
   },
   {
    title: '所属分类',
    align:"center",
    dataIndex: 'classifyId_dictText'
   },
   {
    title: '资源标题',
    align:"center",
    dataIndex: 'title'
   },
   {
    title: '资源链接',
    align:"center",
    dataIndex: 'link'
   },
   {
    title: '排序',
    align:"center",
    dataIndex: 'sort'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '富文本',
    align:"center",
    dataIndex: 'richText',
   },
   {
    title: '点击量',
    align:"center",
    dataIndex: 'clickNumber'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "资源标题",
    field: "title",
    component: 'JInput',
  },
  {
    label: "资源链接",
    field: "link",
    component: 'JInput',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '缩略图',
    field: 'thumbnail',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '所属分类',
    field: 'classifyId',
    component: 'JLinkTableCard',
    componentProps: {
     valueField: 'id',
     textField: 'title,description',
     tableName: 'db_classify',
     multi: false
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属分类!'},
          ];
     },
  },
  {
    label: '资源标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入资源标题!'},
          ];
     },
  },
  {
    label: '资源链接',
    field: 'link',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入资源链接!'},
          ];
     },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'Input',
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '富文本',
    field: 'richText',
    component: 'JEditor',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  thumbnail: {title: '缩略图',order: 0,view: 'image', type: 'string',},
  classifyId: {title: '所属分类',order: 1,view: 'link_table', type: 'string',},
  title: {title: '资源标题',order: 2,view: 'text', type: 'string',},
  link: {title: '资源链接',order: 3,view: 'text', type: 'string',},
  sort: {title: '排序',order: 4,view: 'text', type: 'string',},
  description: {title: '描述',order: 5,view: 'textarea', type: 'string',},
  richText: {title: '富文本',order: 6,view: 'umeditor', type: 'string',},
  clickNumber: {title: '点击量',order: 7,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}